﻿using Hx.ADSyncPlatform.ActiveDirectory.Model;
using System.Collections.Generic;
using System.Linq;

namespace Hx.ADSyncPlatform.ActiveDirectory.Extension
{
    public static class OrgToTreeNode
    {

        public static OuTreeModel ConvertToTree(this Organization organization)
        {
            OuTreeModel ouTreeModel = new OuTreeModel()
            {
                data = organization,
                label = organization.Name,
                id = organization.DistinguishedName

            };
            return ouTreeModel;
        }

        public static List<OuTreeModel> ConvertToTree(this IEnumerable<Organization> organizations)
        {
            return organizations.Select(n =>
            {
                return n.ConvertToTree();
            }).ToList();
        }
    }
}
